2 #ifndef FRAMELIB_MULTISTREAM_H 3 #define FRAMELIB_MULTISTREAM_H 46 {
setIO(nIns, nOuts); }
74 void setIO(
unsigned long nIns,
unsigned long nOuts,
unsigned long nAudioChans = 0)
92 void connectionUpdate(
Queue *queue)
final 98 virtual bool inputUpdate() = 0;
99 void outputUpdate(
Queue *queue);
109 unsigned long mNumStreams;
136 mBlocks.add(
new T(context, serialisedParameters, proxy));
137 mBlocks[0]->setStream(
this, 0);
141 mSerialisedParameters.write(serialisedParameters);
151 for (
unsigned long i = 0; i <
getNumOuts(); i++)
164 void setFixedInput(
unsigned long idx,
double *input,
unsigned long size)
override 166 if (idx < mFixedInputs.size())
168 mFixedInputs[idx].assign(input, input + size);
169 updateFixedInput(idx);
173 const double *
getFixedInput(
unsigned long idx,
unsigned long *size)
override 175 return mBlocks[0]->getFixedInput(idx, size);
182 unsigned long internalNumIns = mBlocks[0]->getNumAudioIns();
183 unsigned long internalNumOuts = mBlocks[0]->getNumAudioOuts();
188 mAudioTemps[0] = alloc<double>(blockSize * internalNumOuts);
189 for (
unsigned long i = 1; i < internalNumOuts; i++)
190 mAudioTemps[i] = mAudioTemps[0] + (i * blockSize);
195 std::fill_n(outs[i], blockSize, 0.0);
199 for (
unsigned long i = 0; i < mBlocks.size(); i++)
201 unsigned long inStreamOffset = internalNumIns * (i %
getNumStreams());
202 unsigned long outStreamOffset = internalNumOuts * (i %
getNumStreams());
204 mBlocks[i]->blockUpdate(ins + inStreamOffset, mAudioTemps.data(),
blockSize);
206 for (
unsigned long j = 0; j < internalNumOuts; j++)
207 for (
unsigned long k = 0; k <
blockSize; k++)
208 outs[outStreamOffset + j][k] += mAudioTemps[j][k];
221 void reset(
double samplingRate,
unsigned long maxBlockSize)
override 223 mSamplingRate = samplingRate;
224 mMaxBlockSize = maxBlockSize;
226 for (
auto it = mBlocks.begin(); it != mBlocks.end(); it++)
227 (*it)->reset(samplingRate, maxBlockSize);
236 std::string
objectInfo(
bool verbose)
override {
return mBlocks[0]->objectInfo(verbose); }
237 std::string
inputInfo(
unsigned long idx,
bool verbose)
override {
return mBlocks[0]->inputInfo(idx, verbose); }
238 std::string
outputInfo(
unsigned long idx,
bool verbose)
override {
return mBlocks[0]->outputInfo(idx, verbose); }
240 std::string
audioInfo(
unsigned long idx,
bool verbose)
override 254 for (
auto it = mBlocks.begin(); it != mBlocks.end(); it++)
255 (*it)->autoOrderingConnections();
260 for (
auto it = mBlocks.begin(); it != mBlocks.end(); it++)
261 (*it)->clearAutoOrderingConnections();
268 void updateFixedInput(
unsigned long idx)
270 for (
unsigned long i = 0; i < mBlocks.size(); i++)
271 mBlocks[i]->
setFixedInput(idx, mFixedInputs[idx].data(), mFixedInputs[idx].size());
276 bool inputUpdate()
override 280 unsigned long nChannels = 1;
281 unsigned long cChannels = mBlocks.size();
283 for (
unsigned long i = 0; i <
getNumIns(); i++)
291 bool numChansChanged = nChannels != cChannels;
297 if (nChannels > cChannels)
299 for (
unsigned long i = cChannels; i < nChannels; i++)
302 mBlocks.back()->setStream(
this, i);
303 mBlocks.back()->reset(mSamplingRate, mMaxBlockSize);
307 mBlocks.resize(nChannels);
311 for (
unsigned long i = 0; i <
getNumOuts(); i++)
314 for (
unsigned long i = 0; i <
getNumOuts(); i++)
315 for (
unsigned long j = 0; j < nChannels; j++)
320 for (
unsigned long i = 0; i <
getNumIns(); i++)
326 for (
unsigned long i = 0; i <
getNumIns(); i++)
330 for (
unsigned long j = 0; j < nChannels; j++)
335 for (
unsigned long j = 0; j < nChannels; j++)
342 for (
unsigned long j = 0; j < nChannels; j++)
350 for (
unsigned long j = 0; j < nChannels; j++)
354 return numChansChanged;
362 std::vector<std::vector<double>> mFixedInputs;
364 unsigned long mMaxBlockSize;
365 double mSamplingRate;
367 std::vector<double *> mAudioTemps;
ObjectType
Definition: FrameLib_Types.h:53
holds the connected object and IO indices for a connection to an object
Definition: FrameLib_Object.h:143
void deleteConnection(unsigned long inIdx)
Definition: FrameLib_Object.h:260
static bool handlesAudio()
Definition: FrameLib_Multistream.h:62
ConnectionResult addOrderingConnection(Connection connection)
Definition: FrameLib_Object.h:265
const FrameLib_Parameters * getParameters() const override
Definition: FrameLib_Multistream.h:248
unsigned long getNumOuts() const
Definition: FrameLib_Object.h:217
a set of parameters for a FrameLib object.
Definition: FrameLib_Parameters.h:30
FrameLib_Proxy * getProxy() const
Definition: FrameLib_Object.h:212
void clearAutoOrderingConnections() override
Definition: FrameLib_Multistream.h:258
BlockConnection getInputChan(unsigned long inIdx, unsigned long chan)
Definition: FrameLib_Multistream.cpp:15
a class used to represent distinct non-connectable areas in the host environment. ...
Definition: FrameLib_Context.h:21
FrameLib_Expand(FrameLib_Context context, FrameLib_Parameters::Serial *serialisedParameters, FrameLib_Proxy *proxy, unsigned long nStreams)
Definition: FrameLib_Multistream.h:131
static bool handlesAudio()
Definition: FrameLib_Multistream.h:232
a set of tagged parameter values using external non-owned memory.
Definition: FrameLib_Parameters.h:51
void dealloc(U *&ptr)
Definition: FrameLib_Object.h:400
unsigned long getInputNumChans(unsigned long inIdx)
Definition: FrameLib_Multistream.cpp:8
unsigned long getNumAudioChans() const
Definition: FrameLib_Object.h:220
a virtual struct allowing for extensible communication to/from the host environment.
Definition: FrameLib_Types.h:69
ObjectType getType() const
Definition: FrameLib_Object.h:204
void setIO(unsigned long nIns, unsigned long nOuts, unsigned long nAudioChans=0)
Definition: FrameLib_Multistream.h:74
std::vector< BlockConnection > MultistreamOutput
Definition: FrameLib_Multistream.h:35
std::vector< MultistreamOutput > mOutputs
Definition: FrameLib_Multistream.h:105
an abstract template class providing an interface for FrameLib objects and implementing connectivity ...
Definition: FrameLib_Object.h:128
virtual void setFixedInput(unsigned long idx, double *input, unsigned long size)=0
void reset(double samplingRate, unsigned long maxBlockSize) override
Definition: FrameLib_Multistream.h:221
void blockUpdate(const double *const *ins, double **outs, unsigned long blockSize) override
Definition: FrameLib_Multistream.h:180
const FrameLib_Parameters::Serial * getSerialised() override
Definition: FrameLib_Multistream.h:129
ConnectionResult addConnection(Connection connection, unsigned long inIdx)
Definition: FrameLib_Object.h:254
void clearAllocator()
Definition: FrameLib_Object.h:406
std::string audioInfo(unsigned long idx, bool verbose) override
Definition: FrameLib_Multistream.h:240
std::string objectInfo(bool verbose) override
Definition: FrameLib_Multistream.h:236
a template class for providing multi-stream support to any FrameLib_Block class.
Definition: FrameLib_Multistream.h:124
FrameLib_Context getContext() const
Definition: FrameLib_Object.h:208
virtual ~FrameLib_Multistream()
Definition: FrameLib_Multistream.h:53
void clearOrderingConnections()
Definition: FrameLib_Object.h:280
FrameLib_Multistream(ObjectType type, FrameLib_Context context, FrameLib_Proxy *proxy, unsigned long nStreams, unsigned long nIns, unsigned long nOuts)
Definition: FrameLib_Multistream.h:44
bool supportsOrderingConnections() const
Definition: FrameLib_Object.h:337
virtual void reset(double samplingRate, unsigned long maxBlockSize)=0
virtual const FrameLib_Parameters::Serial * getSerialised()=0
FrameLib_Object< FrameLib_Block >::Connection BlockConnection
Definition: FrameLib_Multistream.h:34
FrameLib_Multistream & operator=(const FrameLib_Multistream &)=delete
FrameType outputType(unsigned long idx) const override
Definition: FrameLib_Multistream.h:246
size_t blockSize(void *ptr)
Definition: FrameLib_Memory.cpp:23
void enableOrderingConnections()
Definition: FrameLib_Object.h:391
const double * getFixedInput(unsigned long idx, unsigned long *size) override
Definition: FrameLib_Multistream.h:173
FrameType inputType(unsigned long idx) const override
Definition: FrameLib_Multistream.h:245
unsigned long getNumOrderingConnections() const
Definition: FrameLib_Object.h:338
virtual std::string audioInfo(unsigned long idx, bool verbose=false)
Definition: FrameLib_Object.h:243
std::string inputInfo(unsigned long idx, bool verbose) override
Definition: FrameLib_Multistream.h:237
void setIO(unsigned long nIns, unsigned long nOuts, unsigned long nAudioChans=0)
Definition: FrameLib_Object.h:381
FrameLib_Multistream(ObjectType type, FrameLib_Context context, FrameLib_Proxy *proxy, unsigned long nStreams)
Definition: FrameLib_Multistream.h:48
unsigned long getNumAudioOuts() const
Definition: FrameLib_Object.h:219
an extension of Serial that manages its own resizable memory.
Definition: FrameLib_Parameters.h:250
void setFixedInput(unsigned long idx, double *input, unsigned long size) override
Definition: FrameLib_Multistream.h:164
FrameType
Definition: FrameLib_Types.h:54
static const char * formatInfo(const char *verboseStr, const char *briefStr, bool verbose)
Definition: FrameLib_Object.h:418
unsigned long getOrderingConnectionNumChans(unsigned long idx)
Definition: FrameLib_Multistream.cpp:22
a abstract class proving multi-stream connnections and the means to the number of streams in a networ...
Definition: FrameLib_Multistream.h:29
void autoOrderingConnections() override
Definition: FrameLib_Multistream.h:252
unsigned long getNumStreams()
Definition: FrameLib_Multistream.h:66
typename FrameLib_Queueable< FrameLib_Multistream >::Queue Queue
Definition: FrameLib_Object.h:133
BlockConnection getOrderingConnectionChan(unsigned long idx, unsigned long chan)
Definition: FrameLib_Multistream.cpp:29
unsigned long getNumIns() const
Definition: FrameLib_Object.h:216
std::string outputInfo(unsigned long idx, bool verbose) override
Definition: FrameLib_Multistream.h:238